package com.quarantine.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.quarantine.dao.administratorDao;
import com.quarantine.model.administrator;

@Component
@Transactional
public class AdministratorManager {
	private administratorDao administratorDao;

	@Autowired
	public void setAdministratorDao(administratorDao administratorDao) {
		this.administratorDao = administratorDao;
	}

	/**
	 * 通过id查找对象
	 * 
	 * @param id
	 * @return
	 */
	public administrator getById(String id) {
		return administratorDao.findUniqueBy("id", id);
	}

	public administrator findByLoginName(String username) {
        System.out.println(username);
		return administratorDao.findUniqueBy("loginName", username);
	}

	/**
	 * 保存对象
	 * 
	 * @param entity
	 */
	public void save(administrator entity) {
		administratorDao.save(entity);
	}

	/**
	 * 
	 * 批量删除
	 * 
	 * @param ids
	 *            id逗号隔开
	 */
	public void deleteByIds(String ids) {
		for (String id : ids.split(",")) {
			administratorDao.delete(id.trim());
		}
	}

}
